package control;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Actor;
public class DelActor extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public DelActor() {
        super();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		String n = request.getParameter("acid");
		String del = request.getParameter("delete");
		
		if (del.equals("yes")) {
			Actor actor = new Actor();
			if (actor.del(Integer.parseInt(n))) {
			request.setAttribute("m", "del-acok");
			request.setAttribute("r","vac");
			RequestDispatcher transferexist = getServletContext().getRequestDispatcher("/a/message.jsp");
			transferexist.forward(request, response);
			}else{
				request.setAttribute("m", "err-delac");
				request.setAttribute("r","vac");
				RequestDispatcher transferexist = getServletContext().getRequestDispatcher("/a/message.jsp");
				transferexist.forward(request, response);
			}
		} else {
			RequestDispatcher transfer = getServletContext().getRequestDispatcher("/a/actor.jsp");
			transfer.forward(request, response);
		}
	}

}
